<template>
  <div>
    <button @click="goToPage1">新建会话</button>
    <button @click="goToPage2">打开会话</button>
  </div>
</template>

<script>
const axios = require('axios').default;

export default {
  name: 'Session',
  data() {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  },
  methods: {
    goToPage1() {
      axios.post("http://127.0.0.1:8081", {
          "type": "notebook",
          "path": ""
        })
        .then((data) => {
          console.info("data:", data)
          this.$router.push({
            name: 'Subpages',
            query:{
              fileName: data.data.name
            }
          });
        })
    },
    goToPage2() {
      this.$router.push('/page2')
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped></style>
